//
//  HTTPHelper.h
//  Perking
//
//  Created by longmin on 16/7/12.
//  Copyright © 2016年 tim. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HTTPStatus.h"

@interface HTTPHelper : AFHTTPSessionManager

+ (nonnull instancetype)sharedHTTPHelper;
/** get请求 */
-(nullable NSURLSessionDataTask *)get:(nonnull NSString *)URLString
                               params:(nullable NSDictionary *)params
                             useToken:(BOOL)useToken
                             progress:(nullable void (^)(NSProgress * _Nonnull downloadProgress))downloadProgress
                              success:(nullable void (^)(NSURLSessionDataTask * _Nonnull task,NSDictionary * _Nullable result, HTTPStatus * _Nonnull status))success
                              failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
/** get请求,带HUD显示文字 */
-(nullable NSURLSessionDataTask *)get:(nonnull NSString *)URLString
                               params:(nullable NSDictionary *)params
                             useToken:(BOOL)useToken
                             showText:(nullable NSString *)showText
                              success:(nullable void (^)(NSURLSessionDataTask * _Nonnull task,NSDictionary *_Nullable result, HTTPStatus * _Nonnull status))success
                              failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *_Nonnull error))failure;
/** post请求 */
-(nullable NSURLSessionDataTask *)post:(nonnull NSString *)URLString
                                params:(nullable NSDictionary *)params
                              useToken:(BOOL)useToken
                              progress:(nullable void (^)(NSProgress *_Nonnull uploadProgress)) uploadProgress
                               success:(nullable void (^)(NSURLSessionDataTask * _Nonnull task,NSDictionary * _Nullable result, HTTPStatus * _Nonnull status))success
                               failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *_Nonnull error))failure;
/** post请求,带HUD显示文字 */
-(nullable NSURLSessionDataTask *)post:(nonnull NSString *)URLString
                                params:(nullable NSDictionary *)params
                              useToken:(BOOL)useToken
                              showText:(nullable NSString *)showText
                               success:(nullable void (^)(NSURLSessionDataTask * _Nonnull task,NSDictionary * _Nullable result, HTTPStatus * _Nonnull status))success
                               failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *_Nonnull error))failure;
/** post上传 */
- (nullable NSURLSessionDataTask *)post:(nonnull NSString *)URLString
                                 params:(nullable NSDictionary *)params
                               useToken:(BOOL)useToken
              constructingBodyWithBlock:(nullable void (^)(id <AFMultipartFormData> _Nonnull formData))block
                               progress:(nullable void (^)(NSProgress *_Nonnull uploadProgress)) uploadProgress
                                success:(nullable void (^)(NSURLSessionDataTask * _Nonnull task,NSDictionary * _Nullable result, HTTPStatus * _Nonnull status))success
                                failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *_Nonnull error))failure;
/** 同步Get请求 */
- (void)syncGet:(nonnull NSString *)URLString
         params:(nullable NSDictionary *)params
       useToken:(BOOL)useToken
        success:(nullable void (^)(NSURLSessionDataTask * _Nonnull task,NSDictionary * _Nullable result, HTTPStatus * _Nonnull status))success
        failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;
/** 同步POST请求 */
- (void)syncPost:(nonnull NSString *)URLString
          params:(nullable NSDictionary *)params
        useToken:(BOOL)useToken
         success:(nullable void (^)(NSURLSessionDataTask * _Nonnull task,NSDictionary * _Nullable result, HTTPStatus * _Nonnull status))success
         failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error))failure;

/**
 *  sha1加密
 *  @param input 要加密的字符串
 *  return 加密好的字符串
 */
- (nullable NSString *) sha1:(nullable NSString *)input;
/**
 *  快捷设置请求头 Access-Token Access-Key Authorization
 *  @param params 请求的参数
 *  @param useToken 是否要设置token进请求头
 */
//- (void)setHeader:(nullable NSDictionary *)params useToken:(BOOL)useToken;

@end
